package mission4propre;

public class LivreRef implements Comparable<LivreRef>{

	public static int Field=1;
	private String titre=null;
	private String num=null;
	private String rang=null;

	private String ROF1name=null;
	private String ROF2=null;
	private String ROF2name=null;
	private String ROF3=null;
	private String ROF3name=null;

	public LivreRef(String titre, String num,String rang){
		this.titre=titre;
		this.num=num;
		this.rang=rang;
	}

	public LivreRef() {
	}

	public LivreRef(String title) {
		this.titre=title;
	}

	/**
	 * @return the titre
	 */
	public String getTitre() {
		return titre;
	}
	/**
	 * @param titre the titre to set
	 */
	public void setTitre(String titre) {
		this.titre = titre;
	}
	/**
	 * @return the num
	 */
	public String getNum() {
		return num;
	}
	/**
	 * @param num the num to set
	 */
	public void setNum(String num) {
		this.num = num;
	}
	/**
	 * @return the rang
	 */
	public String getRang() {
		return rang;
	}
	/**
	 * @param rang the rang to set
	 */
	public void setRang(String rang) {
		this.rang = rang;
	}

	/**
	 * @return the rOF1name
	 */
	public String getROF1name() {
		return ROF1name;
	}

	/**
	 * @param rOF1name the rOF1name to set
	 */
	public void setROF1name(String rOF1name) {
		ROF1name = rOF1name;
	}

	/**
	 * @return the rOF2
	 */
	public String getROF2() {
		return ROF2;
	}

	/**
	 * @param rOF2 the rOF2 to set
	 */
	public void setROF2(String rOF2) {
		ROF2 = rOF2;
	}

	/**
	 * @return the rOF2name
	 */
	public String getROF2name() {
		return ROF2name;
	}

	/**
	 * @param rOF2name the rOF2name to set
	 */
	public void setROF2name(String rOF2name) {
		ROF2name = rOF2name;
	}

	/**
	 * @return the rOF3
	 */
	public String getROF3() {
		return ROF3;
	}
	/**
	 * @param rOF3 the rOF3 to set
	 */
	public void setROF3(String rOF3) {
		ROF3 = rOF3;
	}

	/**
	 * @return the rOF3name
	 */
	public String getROF3name() {
		return ROF3name;
	}

	/**
	 * @param rOF3name the rOF3name to set
	 */
	public void setROF3name(String rOF3name) {
		ROF3name = rOF3name;
	}
	/**
	 * This function returns a String to be display when we make a search.
	 */
	public String toString(){
		String chaine = "Titre: "+this.getTitre()
				+((!this.getRang().equals(""))?"\nRang: "+this.getRang():"")
				+((!this.getNum().equals(""))?"\nROF1: "+this.getNum():"")
				+((!this.getROF1name().equals(""))?"\nROF1name: "+this.getROF1name():"")
				+((!this.getROF2().equals(""))?"\nROF2: "+this.getROF2():"")
				+((!this.getROF2name().equals(""))?"\nROF2name: "+this.getROF2name():"")
				+((!this.getROF3().equals(""))?"\nROF3: "+this.getROF3():"")
				+((!this.getROF3name().equals(""))?"\nROF3name: "+this.getROF3name():"");
		return chaine;
	}

	@Override
	public int compareTo(LivreRef o) throws NullPointerException{
		switch(Field){
			case 1 : return titre.compareTo(o.getTitre());
			case 2 : return num.compareTo(o.getNum());
			case 3 : return rang.compareTo(o.getRang());
			case 4 : return ROF1name.compareTo(o.getROF1name());
			case 5 : return ROF2name.compareTo(o.getROF2name());
			case 6 : return ROF2.compareTo(o.getROF2());
			case 7 : return ROF3.compareTo(o.getROF3());
			case 8 : return ROF3name.compareTo(o.getROF3name());
			default: return titre.compareTo(o.getTitre());
		}			
	}
	
}